import { request } from '@/utils/requestWrapper';
import { tokenStore } from "@/store/tokenStore";

import type { API } from '@/backend/typings.d';

const tokenStoreInstance = tokenStore();

/** 添加用户优惠券(购买优惠券) POST /api/userCoupon/add */
export async function addUserCouponUsingPost(
  body: API.UserCouponAddRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseLong_>({
    url: "/api/userCoupon/add",
    method: "POST",
    data: body,
    header: {
      'Authorization': tokenStoreInstance.getToken
    },
    ...(options || {})
  });
}

/** 获取订单可用优惠券列表 GET /api/userCoupon/my/canUser */
export async function listOrderCanUseCouponUsingGet(
  params: {
    orderId?: number;
    money?: number;
  },
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseListCouponVO_>({
    url: "/api/userCoupon/my/canUser",
    method: "GET",
    params,
    header: {
      'Authorization': tokenStoreInstance.getToken
    },
    ...(options || {})
  });
}

/** 分页获取我的优惠券列表 POST /api/userCoupon/my/list/page/vo */
export async function listMyUserCouponVoByPageUsingPost(
  body: API.UserCouponQueryRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponsePageUserCouponVO_>({
    url: "/api/userCoupon/my/list/page/vo",
    method: "POST",
    data: body,
    header: {
      'Authorization': tokenStoreInstance.getToken
    },
    ...(options || {})
  });
} 